"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = useNow;
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _react = require("react");
function useNow(options) {
  var _ref = options !== null && options !== void 0 ? options : {},
    _ref$ms = _ref.ms,
    ms = _ref$ms === void 0 ? 1000 : _ref$ms;
  var _useState = (0, _react.useState)(Date.now()),
    _useState2 = (0, _slicedToArray2.default)(_useState, 2),
    now = _useState2[0],
    setNow = _useState2[1];
  (0, _react.useEffect)(function () {
    var interval = setInterval(function () {
      console.log(111);
      setNow(Date.now());
    }, ms);
    return function () {
      return clearInterval(interval);
    };
  }, []);
  console.log(now);
  return {
    now: now
  };
}